from models.models import User
from django.contrib.auth.backends import BaseBackend


class CustomerAuthBackend(BaseBackend):

    def authenticate(self, request, openid=None, **kwargs):
        try:
            user, new = User.objects.get_or_create(openid=openid)
            return user
        except User.DoesNotExist:
            return None